package com.example.bzh.gamecat.ui.cattery.personal;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.bzh.gamecat.R;
import com.fyales.tagcloud.library.TagBaseAdapter;

import java.util.List;
import java.util.Random;

/**
 * Created by lenovo on 2016/8/16.
 */
public class HotTagAdapter extends TagBaseAdapter {
    private   List<String> list ;
    public HotTagAdapter(Context context, List<String> list) {
        super(context, list);
        this.list = list;
    }

    @Override
    public int getCount() {
        return list!=null?list.size():0;
    }

    @Override
    public String getItem(int position) {
        return list!=null?list.get(position):null;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView view = (TextView) super.getView(position, convertView, parent);
        //LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(100,40);
      //  view.setLayoutParams(params);
       // int[] color = new int[]{Color.YELLOW,Color.BLUE,Color.GREEN,Color.RED};
        int[] color = new int[]{R.mipmap.tag_color_yellow,R.mipmap.tag_color_blue,R.mipmap.tag_color_orange,R.mipmap.tag_color_red};
        //int[] color = new int[]{R.drawable.tag_color_yellow,R.drawable.tag_color_blue,R.drawable.tag_color_orange,R.drawable.tag_color_red};
        int index = (int) (Math.random()*(color.length));
        int bgColor = color[index];
        view.setBackgroundResource(bgColor);
        return view;
    }
}
